/*
* @Author: dengjiayao
* @Date:   2017-08-28 17:19:29
 * @Last Modified by: songwh
 * @Last Modified time: 2018-08-10 17:31:00
*/
import { modal } from 'vue-strap'
import { showMsg, updateKeyEventsStatus, dependValueDescList, eventKpiList} from '../../../vuex/action'
import DatePicker from 'vue-datepicker'

import getDatePickerOption from '../../../util/date-picker-option'

export default {
  data() {
    return {
      showModal: false,
      actionType: 'ADD', // ADD or UPDATE
      typeList: [],
      form: {
        eventType:'',
        eventDesc: '',
        startDt: '',
        endDt: '',
        status: '',
        eventLink: '',
        eventKpis: []
      },
      eventKpis: [],
      datePickerOption: getDatePickerOption({
        format: 'YYYY-MM-DD'
      })
    }
  },
  components: {
    'vue-modal': modal,
    'vue-date-picker': DatePicker
  },
  vuex: {
    actions: {
      xShowMsg: showMsg,
      xUpdateKeyEventsStatus: updateKeyEventsStatus,
      xDependValueDescList: dependValueDescList,
      xEventKpiList: eventKpiList,
    }
  },
  ready() {
    this.getSelectList()
  },
  methods: {
    getKpiList(eventId){
      this.xEventKpiList({
        eventId: eventId
      })
        .then((res) => {
          this.eventKpis = res.list
        })
    },
    getSelectList(){
      this.xDependValueDescList({
        columName: 'event_type',
        dependValue: '2' 
      })
        .then((res) => {
          this.typeList = res.list
        })
    },
    submit(eventId) {
      let params = {
        eventId: eventId,
        status: '5'
      }
      this.xUpdateKeyEventsStatus(params)
        .then((res) => {
          this.showModal = false
        })
    },
    cancelFun(eventId){
      let params = {
        eventId: eventId,
        status: '7'
      }
      this.xUpdateKeyEventsStatus(params)
        .then((res) => {
          this.showModal = false
        })
    },
    addCode() {
    }
  }
}
